﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="RtuReadRequestPackage.cs" company="R.V.Kasner">
//   Copyright © 2011 R.V.Kasner
// </copyright>
// --------------------------------------------------------------------------------------------------------------------

namespace Owen.Communication.NewProtocols.ModBus.Rtu
{
    using System.Collections.Generic;

    using Owen.Communication.Utility;

    public abstract class RtuReadRequestPackage : RtuPackageBase
    {
        protected RtuReadRequestPackage()
        {
            this.CountRegisters = 1;
            this.StartRegisterNumber = 0;
        }

        public int CountRegisters { get; set; }

        public int StartRegisterNumber { get; set; }

        protected override IEnumerable<int> GetData()
        {
            ShortAccessor sacount = this.CountRegisters;
            ShortAccessor sastart = this.StartRegisterNumber;
            return new int[] { sastart.HighByte, sastart.LowByte, sacount.HighByte, sacount.LowByte };
        }
    }
}